package com.base;

import android.content.Context;
import android.os.Bundle;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.viewbinding.ViewBinding;

import com.training.event.DefaultEvent;
import com.training.net.DataCenter;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

public abstract class BaseActivity<T extends ViewBinding> extends AppCompatActivity implements BaseInterface<T>{
    public T mBinding;
    public Context context;
    public DataCenter dc;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mBinding = binding();
        context = this;
        dc=DataCenter.instance();
        setContentView(mBinding.getRoot());
        EventBus.getDefault().register(this);
        onCreated(savedInstanceState);
    }
    @Subscribe(threadMode = ThreadMode.MAIN)
    public void onDefaultEvent(DefaultEvent mEvent) {

    }
    @Override
    protected void onDestroy() {
        super.onDestroy();
        dc=null;
        context=null;
        EventBus.getDefault().unregister(this);
    }
}
